package com.ztk.threadbasic.threadlocal;

public class ThreadLocal01 {
    private String content;

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public static void main(String[] args) {
        ThreadLocal01 threadLocal01 = new ThreadLocal01();
        for (int i = 0; i < 500; i++) {
            Thread thread = new Thread(() -> {
                threadLocal01.setContent(Thread.currentThread().getName());
                try {
                    Thread.sleep(1);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println(Thread.currentThread().getName() + "->" + threadLocal01.getContent());
            });
            thread.setName("线程" + i);
            thread.start();
        }

    }
}
